package com.xiaoyu.base.entity;

import android.text.TextUtils;

import androidx.annotation.NonNull;
import androidx.room.Entity;
import androidx.room.PrimaryKey;

import java.util.Objects;

import in.srain.cube.request.JsonData;

@Entity(tableName = "user")
public class UserEntity {

    @PrimaryKey
    @NonNull
    private String uid;
    private String avatar;
    private String decorateIcon;
    private String decorateKey;
    private String guardKey;
    private String exAvatar;
    private String name;
    private String sex;

    public UserEntity() {
        uid = "";
        avatar = "";
        decorateIcon = "";
        decorateKey = "";
        guardKey = "";
        exAvatar = "";
        name = "";
        sex = "";
    }

    public UserEntity(JsonData jsonData) {
        uid = jsonData.optString("id");
        avatar = jsonData.optString("avatar");
        decorateIcon = jsonData.optString("decorate_icon");
        decorateKey = jsonData.optString("decorate_key");
        guardKey = jsonData.optString("guard_key");
        exAvatar = jsonData.optString("ex_avatar");
        sex = jsonData.optString("sex");
        name = jsonData.optString("name");
    }

    public String getUid() {
        return uid;
    }

    public void setUid(String uid) {
        this.uid = uid;
    }

    public String getAvatar() {
        return avatar;
    }

    public void setAvatar(String avatar) {
        this.avatar = avatar;
    }

    public String getDecorateIcon() {
        return decorateIcon;
    }

    public void setDecorateIcon(String decorateIcon) {
        this.decorateIcon = decorateIcon;
    }

    public String getDecorateKey() {
        return decorateKey;
    }

    public void setDecorateKey(String decorateIcon) {
        this.decorateKey = decorateIcon;
    }

    public String getGuardKey() {
        return guardKey;
    }

    public void setGuardKey(String guardKey) {
        this.guardKey = guardKey;
    }

    public String getExAvatar() {
        return exAvatar;
    }

    public void setExAvatar(String exAvatar) {
        this.exAvatar = exAvatar;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getSex() {
        return sex;
    }

    public void setSex(String sex) {
        this.sex = sex;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (o == null || getClass() != o.getClass()) {
            return false;
        }
        UserEntity that = (UserEntity) o;
        if (!TextUtils.equals(uid, that.uid)) {
            return false;
        }
        if (!TextUtils.equals(sex, that.sex)) {
            return false;
        }
        if (!TextUtils.equals(avatar, that.avatar)) {
            return false;
        }
        if (!TextUtils.equals(decorateKey, that.decorateKey)) {
            return false;
        }
        if (!TextUtils.equals(exAvatar, that.exAvatar)) {
            return false;
        }
        if (!TextUtils.equals(name, that.name)) {
            return false;
        }
        return true;
    }

    @Override
    public int hashCode() {
        return Objects.hash(uid);
    }

    @NonNull
    @Override
    public String toString() {
        return "UserEntity{" +
                "uid='" + uid + '\'' +
                ", avatar='" + avatar + '\'' +
                ", decorateKey='" + decorateKey + '\'' +
                ", exAvatar='" + exAvatar + '\'' +
                ", name='" + name + '\'' +
                ", sex=" + sex +
                '}';
    }
}
